<template>
  <div class="c-upload-single" @click="handleClick">
    <slot></slot>
    <input
      ref="upload"
      class="c-upload-single-input"
      type="file"
      @change="handleChange"
    />
  </div>
</template>
<script>
export default {
  name: 'CUploadSingle',
  components: {},
  props: {},
  data() {
    return {}
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    handleClick() {
      this.$refs.upload.click()
    },
    handleChange(e) {
      const file = e.target.files[0]
      this.$emit('change', file)
    }
  }
}
</script>
<style lang="scss">
.c-upload-single {
  font-size: 14px;
  &-input {
    display: none;
  }
}
</style>
